#pragma once

#include <cstdint>
#include "rpc_defines.h"

namespace rpc {

// User implemented interface
class Transport {
public:
    // Send data
    // @param data The data need to send
    // @param size data size in byte
    // @return How many bytes sent, <= 0 means error
    virtual int send(const char* data, int size) = 0;
    // Copy data from stream but doesn't remove it
    // @param data The data need to copy
    // @param size data size in byte
    // @return How many bytes need to copy, <= 0 means error
    virtual int peek(char* data, int size) = 0;
    // Receive data
    // Copy data from stream and remove them
    // @param data The data need to move
    // @param size The data size in byte
    // @return How many bytes need to move, <= 0 means error
    virtual int recv(char* data, int size) = 0;
    // Ignore some bytes in stream
    // @param size The data size in byte need to ignore
    virtual int skip(int size) = 0;
    // Returns how many bytes in stream
    virtual int size() = 0;
    // Check whether stream has been closed
    virtual bool isClose() = 0;
    // Close stream
    virtual void close() = 0;
};

}
